public class Scope
extends java.lang.Object
implements java.lang.Iterable<java.lang.Object>, java.lang.Cloneable
List and Map which allow you to have both variables and independent values managed by one Object. Map methods such as put(String key, Object) and array of independent values is accessed by via List methods such as add(Object) and get(int)Serializer and supposed to be read only!
{
//This is scope in SerialX!
}
| Constructor and Description |
|---|
Scope(java.util.Map<java.lang.String,java.lang.Object> variablesMap,
java.util.Collection<java.lang.Object> values) |
Scope(java.util.Map<java.lang.String,java.lang.Object> variablesMap,
java.lang.Object... values) |
Scope(java.lang.Object... values) |
| Modifier and Type | Method and Description |
|---|---|
Scope |
clone() |
boolean |
containsIndependentValue(java.lang.Object value) |
boolean |
containsVariable(java.lang.String variableName) |
<T> T |
get(int valueIndex) |
<T> T |
get(java.lang.String variableName) |
Scope |
getParent() |
Scope |
getScope(int scopesOrderIndex) |
Scope |
getScope(java.lang.String... scopesPath) |
Scope |
getScopeAt(int scopeValueIndex) |
boolean |
isEmpty() |
java.util.Iterator<java.lang.Object> |
iterator() |
java.lang.String |
toString() |
java.lang.Object[] |
toValArray() |
java.util.List<java.lang.Object> |
toValList() |
java.util.LinkedHashMap<java.lang.String,java.lang.Object> |
toVarMap() |
int |
valuesCount() |
java.util.Set<java.util.Map.Entry<java.lang.String,java.lang.Object>> |
varEntrySet() |
int |
variablesCount() |
@SafeVarargs public Scope(java.lang.Object... values)
values - | Initial independent values to be added in to this scope!@SafeVarargs
public Scope(java.util.Map<java.lang.String,java.lang.Object> variablesMap,
java.lang.Object... values)
variablesMap - | Initial variables to be added in to this scope!values - | Initial independent values to be added in to this scope!public Scope(java.util.Map<java.lang.String,java.lang.Object> variablesMap,
java.util.Collection<java.lang.Object> values)
variablesMap - | Initial variables to be added in to this scope!values - | Initial independent values to be added in to this scope!public java.lang.String toString()
toString in class java.lang.Objectpublic Scope clone()
clone in class java.lang.Objectpublic java.util.Iterator<java.lang.Object> iterator()
iterator in interface java.lang.Iterable<java.lang.Object>public <T> T get(java.lang.String variableName)
variableName - | Variables name.public boolean containsVariable(java.lang.String variableName)
variableName - | Variables name to search for.public boolean containsIndependentValue(java.lang.Object value)
value - | Objecthe value.public <T> T get(int valueIndex)
valueIndex - | Index of independent value. Also can be negative, in this case u will get elements from back!public Scope getScopeAt(int scopeValueIndex)
scopeValueIndex - | Index of sub-scopes value.public Scope getScope(int scopesOrderIndex)
scopesOrderIndex - | Order index of sub-scope.getScopeAt(int) however this will ignore non scope variables.
variable = "something";
"something";
{
"Scope0"
};
123;
null;
{
"Scope1" <- This one will be returned!
};
4;
5;
6;
{
"Scope2"
}
public Scope getScope(java.lang.String... scopesPath)
scopesPath - | Array with variable names creating path to required scope.
variable = "something";
scope1 =
{
subScope =
{
scopeObjectoFind = {...}; <- this one will be returned if getScope("scope1", "scopeObjectoFind") is issued!
7;...
}
};
scopeObjectoFind = {...} <- this one will be returned if getScope("scopeObjectoFind") is issued!
Note: Remember that this search includes variables only, no values!public java.util.Set<java.util.Map.Entry<java.lang.String,java.lang.Object>> varEntrySet()
public int valuesCount()
public int variablesCount()
public boolean isEmpty()
public Scope getParent()
public java.util.LinkedHashMap<java.lang.String,java.lang.Object> toVarMap()
LinkedHashMap with variables of this Scope in defined order! Key is a string name of variable and value is its value! public java.util.List<java.lang.Object> toValList()
ArrayList with independent values of this Scope. These values have nothing to do with values of variables, they are independent!
Modifying this list will not affect this Scope object!public java.lang.Object[] toValArray()